"""应用配置模块"""
from typing import Optional

from pydantic import Field
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    APP_NAME: str = Field(default="FastAPI App")
    VERSION: str = Field(default="0.1.0")
    DEBUG: bool = Field(default=True)
    HOST: str = Field(default="0.0.0.0")
    PORT: int = Field(default=8000)
    # 添加日志配置
    LOG_LEVEL: str = Field(default="INFO")
    # 添加控制日志输出方式的配置
    LOG_TO_CONSOLE: bool = Field(default=True)
    LOG_TO_FILE: bool = Field(default=False)
    LOG_DIR: str = Field(default="./logs")
    LOG_FILE: str = Field(default="app.log")
    
    # Redis配置
    REDIS_HOST: str = Field(default="10.33.105.51")
    REDIS_PORT: int = Field(default=6379)
    REDIS_DB: int = Field(default=1)
    REDIS_PASSWORD: Optional[str] = Field(default=None)
    
    # SQLite 数据库路径配置
    SQLITE_DB_PATH: str = Field(default="./metadata_log.db")
    # schema 文件
    DB_SCHEMA_PATH: str = Field(default="./config/db_schema.json")
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"  # 指定环境文件编码
        extra = "ignore"  # 忽略额外的字段

def get_settings() -> Settings:
    return Settings()